package com.ys.web.pay;

import com.ys.utils.datasource.DataSourceBy;
import com.ys.web.pay.model.PayOrder;
import com.ys.web.pay.model.RedPacket;
import com.ys.web.pay.model.UserAccount;
import com.ys.web.pay.model.UserAccountFlow;
import com.ys.web.pay.model.vo.UserBank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayService {

    @Value("${ys.default.head_img}")
    private String DEFAULT_IMG;

    @Autowired
    private PayMapper payMapper;

    /**
     * 获取当前用户在当前群10分钟之前的未领取红包
     * @param uid
     * @param groupId
     * @return
     */
    public List<RedPacket> getUnGrad(long uid, int groupId){
        return payMapper.getUnGrad(uid, groupId);
    }

    public UserBank getUserBankByUserId(Long userId, String bankId){
        return payMapper.getUserBankByUserId(userId, bankId);
    }

    @DataSourceBy("ysIm")
    public int getUserBankByUserIdCount(Long userId){
        return payMapper.getUserBankByUserIdCount(userId);
    }

    public UserBank getUserBankByUserIdMb(Long userId, String bankId){
        return payMapper.getUserBankByUserIdMb(userId, bankId);
    }
    public void payOrder(PayOrder payOrder){
        payMapper.payOrder(payOrder);
    }

    public int payOrderStatusChange(PayOrder payOrder){
        return payMapper.payOrderStatusChange(payOrder);
    }
    public int payOrderStatusZfb(PayOrder payOrder){
        return payMapper.payOrderStatusZfb(payOrder);
    }
    public int payOrderRefund(PayOrder payOrder){
        return payMapper.payOrderRefund(payOrder);
    }

    public PayOrder payOrderByNo(String orderNo){
        return payMapper.payOrderByNo(orderNo);
    }

    public PayOrder payOrderByOrderId(String orderNo){
        return payMapper.payOrderByOrderId(orderNo);
    }

    public PayOrder payOrderBySerialNumber(String serialNumber){
        return payMapper.payOrderBySerialNumber(serialNumber);
    }

    public void initUserAccount(UserAccount userAccount){payMapper.initUserAccount(userAccount);}
    public void initUserAccountZfb(UserAccount userAccount){payMapper.initUserAccountZfb(userAccount);}
    public UserAccount getAccountByUserId(Long userId){return payMapper.getAccountByUserId(userId);}

    public UserAccount getAccountZfbByUserId(Long userId){return payMapper.getAccountZfbByUserId(userId);}

    public void userAccountFlow(UserAccountFlow userAccountFlow){
        payMapper.userAccountFlow(userAccountFlow);
    }
    public void userAccountZfbFlow(UserAccountFlow userAccountFlow) {
        payMapper.userAccountZfbFlow(userAccountFlow);
    }
    public int userAccountUpdate(UserAccount userAccount){return payMapper.userAccountUpdate(userAccount);}

    public List<PayOrder> getPayOrderListByTime(){return payMapper.getPayOrderListByTime();}

    public int updateStatus(String id){
        return payMapper.updateStatus(id);
    }

    public int userZfbAccountUpdate(UserAccount account) {
        return payMapper.userZfbAccountUpdate(account);
    }

    public UserAccount getAccountHjzfByUserId(long userId) {
        return payMapper.getAccountHjzfByUserId(userId);
    }

    public void initUserAccountHjzf(UserAccount userAccount) {
        payMapper.initUserAccountHjzf(userAccount);
    }

    public int userHjzfAccountUpdate(UserAccount account) {
        return payMapper.userHjzfAccountUpdate(account);
    }

    public UserBank getUserBankByUserIdHjzf(long userId, String bankId) {
        return payMapper.getUserBankByUserIdHjzf(userId, bankId);
    }

    public UserBank getUserBankHjzfByUserId(Long userId, String bankId) {
        return payMapper.getUserBankHjzfByUserId(userId, bankId);
    }

    public UserAccount getAccountHjzgByUserId(long userId) {
        return payMapper.getAccountHjzgByUserId(userId);
    }
}
